<extend name="Base/s3-2"/>
<block name="body"><div id="check">
<div class="mt">
				<h2>填写并核对订单信息</h2>
			</div>
<script type="text/javascript">

	$(document).ready(function(){

  $("#show").click(function(){
  $("#formsender").toggle();
  });
});
function savemsg() { 
//判断是否是默认地址
if (document.getElementById("isdefault").checked==true) {
       var info="yes";
    }
    else {
      var info="no";
    }
	var p=$("#address").val();
	var oid=$("#orderid").val();
	var real=$("#realname").val();
	var ph=$("#phone").val();
	var b=$("#youbian").val();
	
	$.ajax({
type:'post', //传送的方式,get/post
url:'{:U("Shopcart/savemsg")}', //发送数据的地址
data:{posi:p,pho:ph,rel:real,id:oid,msg:info},
 dataType: "json",
success:function(data)
{
if (data.msg=="yes") {
     $("#f_default").remove();var str='<p id="f_default"><input type="radio" name="sender" value="'+data.addressid+'" id="default" checked="checked"/>&nbsp;&nbsp;收件人：'+data.realname+'&nbsp;&nbsp;&nbsp;联系电话：'+data.cellphone+'&nbsp;'+'&nbsp;&nbsp;&nbsp;收货地址：'+data.address+'</p>';
    $("#senderdetail").append(str);}
else{
var str='<p><input type="radio" id="new" name="sender" value="'+data.addressid+'" checked="checked"/>&nbsp;&nbsp;收件人：'+data.realname+'&nbsp;&nbsp;&nbsp;联系电话：'+data.cellphone+'&nbsp;'+'&nbsp;&nbsp;&nbsp;收货地址：'+data.address+'</p>';
 $("#senderdetail").append(str);}

 $("#formsender").toggle();
},
error:function (event, XMLHttpRequest, ajaxOptions, thrownError) {
alert("表单错误，"+XMLHttpRequest+thrownError); }
		})
	 }
function makeorder() {
	//判断默认地址是否选中,获取地址id
   if (document.getElementById("default").checked==true) {
      document.getElementById("senderid").value=document.getElementById("default").value;
	  document.myform.submit();
    }	
 var val=$('input:radio[name="sender"]:checked').val();
	//判断新地址是否选中,获取地址id
	  if(val==null){
	
		 alert("请选择一个地址!");return false;
		}
  else{document.getElementById("senderid").value=val;
	  document.myform.submit();     
            }
		 }
</script>

<script type="text/javascript">  
function checkcode()  //检查优惠券是否可以
{
	var str=$("input#code").val();
if(str!==""){
    $.ajax({
type:'post',
url:'{:U("User/checkcode")}', //发送数据的地址//
data:{couponid:str},
 dataType: "json",
success:function(data)
{if(data.msg=="yes"){
	$("span.tips").html(data.info);
}
else{$("span.tips").empty();
	document.getElementById("code").value="";
	$("span.tips").html(data.info);



}
} 
});//ajax结束

}//if结束
	
	}


</script>  

      <div class="orderplace">
     

<div class="o_title"> <h2>收货人信息 <empty name="uid"><else/><span><a href="javascript:vod(0);" id="show">新增</a></span></empty></h2> </div> 
                     <div id="formwarp" class="place"> 
                     
                     
  <empty name="address"> 
   <div id="senderdetail"></div>
  
                       <div id="formsender" >
<form id="formincart" name="form" >  
      <dl>        <dt>详细地址：</dt>  <dd><input type="text" class="cart_long" id="address" maxlength="40" data-input="text" value="" name="area"><font class="ml10 cleb6100" style="display: none;">详细地址不能为空</font></dd>        </dl>
          <dl>              <dt><span>*</span>收 货 人：</dt>              <dd><input type="text"  class="cart_long" id="realname" maxlength="20" data-input="text" value=""><font class="ml10 cleb6100" style="display: none;">收货人不能为空</font></dd>        </dl>        <dl>              <dt><span></span>手&nbsp;&nbsp;&nbsp;&nbsp;机：</dt>              <dd><input type="text"  class="cart_long" id="phone" maxlength="11" data-msg="收货手机号码格式不正确" data-input="text" data-type="cellphone" value="">&nbsp;用于接收发货通知及送货前确认</dd>        </dl>     
             <dl>                  <dd><input id="isdefault" checked="checked"  name="default" type="checkbox" class="cart_n_box">设为默认地址</dd>        </dl>      
             <dl>                   </dl>      
               <dl>  
			   <dd><a href="javascript:void(0)" class="ncart_btn_on" onclick="savemsg();">保存</a></dd>        </dl>    
 </form></div>
                        <else/>
                        
                        
 <div id="senderdetail">
 <p id="f_default"><input type="radio" id="default" name="sender" checked="checked" value="{$uid|get_addressid}" />&nbsp;收件人：{$uid|get_realname}&nbsp;&nbsp;联系电话:{$uid|get_cellphone}&nbsp;&nbsp;收货地址：{$uid|get_address}  </p>
 
 </div>
                            <div id="formsender" style="display:none">
    <form id="formincart" name="form" >  
      <dl>        <dt>详细地址：</dt>  <dd><input type="text" class="cart_long"  id="address" maxlength="40" data-input="text" value="" name="area"><font class="ml10 cleb6100" style="display: none;">详细地址不能为空</font></dd>        </dl>
          <dl>              <dt><span>*</span>收 货 人：</dt>              <dd><input type="text" class="cart_long"  id="realname" maxlength="20" data-input="text" value=""><font class="ml10 cleb6100" style="display: none;">收货人不能为空</font></dd>        </dl>        <dl>              <dt><span></span>手&nbsp;&nbsp;&nbsp;&nbsp;机：</dt>              <dd><input type="text" class="cart_long"  id="phone" maxlength="11" data-msg="收货手机号码格式不正确" data-input="text" data-type="cellphone" value="">&nbsp;用于接收发货通知及送货前确认</dd>        </dl>     
             <dl>                  <dd><input id="isdefault" checked="checked"  name="default" type="checkbox" class="cart_n_box">设为默认地址</dd>        </dl>      
                
               <dl>    <dd><a href="javascript:void(0)" class="ncart_btn_on" onclick="savemsg();">保存</a></dd>        </dl>    
 </form></div>
   
    </empty>

    
   
    
    
    </div>  </div>     <!--收货信息 结束-->          
               <!--订单支付 开始-->   
              <form action='{:U("Shopcart/createorder")}' method="post" name="myform" id="myform">   <div class="orderplace">             <div class="o_title">     <h2>支付</h2> </div>           
                   <div id="formwarp">   <dl>                              <dt>支付方式：</dt>        <dd>                      <input type="hidden" name="tag"  id="orderid" value="{$tag}">  
                    <input type="hidden" name="sender"  id="senderid" >      
                   
                       <input type="radio" name="PayType" id="huo" checked="checked" value="1">货到付款                 <input type="radio" name="PayType" id="pay"  value="2">在线支付                                                                                                 </dd>                        </dl>                                        
              </div>    </div>         <!--订单支付 结束-->  
			  
			   <!--优惠券开始-->   
                <div class="orderplace">             <div class="o_title">     <h2>优惠券</h2> </div>           
                   <div id="formwarp">   <dl>                              <dt>请输入优惠券代码：</dt>        <dd>                                   
                   
                       <input type="text"  class="cart_long"  name="couponcode"  onblur="checkcode();" id="code" >   <span class="red tips"></span>                                                                                                 </dd>                        </dl>                                        
              </div>    </div>         <!--优惠券结束-->   
			  
			  
			  <!--商品信息 开始-->    
              
               <div class="orderplace">   <div class="o_title">  <h2>商品信息</h2></div>                                   <table border="0" cellspacing="0" cellpadding="0"  class="gridtable cart-2" width="100%">  <tbody><tr class="com_list_tit">        <th>商品名称</th>      <th>规格</th>    <th>单价(元)</th> <th>数量</th>   </tr>   <volist name="shoplist" id="vo">  
             <tr>
                <td><A href="{:U('Article/detail?id='.$vo['goodid'])}" > {$vo.goodid|get_good_name}</A></td>
               <td align="center"> <span class="weight">{$vo.parameters|default="无"}</span></td>
                <td align="center">{$vo.price}</td>
                <td align="center">{$vo.num}</td>
                 
            </tr>
          </volist>                    </tbody></table>                     </div>            <!--商品信息 结束-->   
                   <!--发票信息 开始-->         <div class="orderplace fapiao">
                  <h2> 发票信息</h2>   
                  <p>发票信息：不需要发票</p>   
                    <p>很抱歉，近期我们暂时不能提供发票。请联系4008-000-917申请，我们将尽快为您补寄。                              </p>                       
 </div>             
                   <!--发票信息 结束-->            <!--提交信息 开始-->           
                    <div class="orderplace trans"> 
                      <p><b >{$num}</b>件商品</p>     
                     <p>商品金额<b>{$total}</b>元 </p>                     
                       <p>运费<b >{$trans}</b>元</p>
                       <p><input type="checkbox" name="score" id="huo" value="{$uid|get_score}"> <b class="red" ><strong>积分{$uid|get_score}，可兑换成{$ratio}元</strong></b></p>
                          <p class="jiesuan">应付总额 <span id="TotalNeedPay" class="red">￥{$all}</span>元 <a class="btn_submit_pay"   onclick="makeorder();return false" >提交订单</a>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>            <!--提交信息 结束-->              

   
</div>   </form> 
 
     
   
</block>
